ApplicationSet Specification

The following describes all the available fields of an ApplicationSet:

  1. apiVersion: argoproj.io/v1alpha1
  2. kind: ApplicationSet
  3. metadata:
  4. name: test-hello-world-appset
  5. namespace: argocd
  6. # To preserve this annotation and label we can use the preservedFields property
  7. preservedFields:
  8. # This annotation and label exists only on this Application, and not in
  9. # the parent ApplicationSet template:
  10. # ignoreApplicationDifferences is the preferred way to accomplish this now.
  11. annotations:
  12. my-custom-annotation: some-value
  13. labels:
  14. my-custom-label: some-value
  15. spec:
  16. generators:
  17. # Using a generator plugin without combining it with Matrix or Merge
  18. # Plugins allow you to provide your own generator
  19. - plugin:
  20. # Specify the configMap where the plugin configuration is located.
  21. configMapRef:
  22. name: my-plugin
  23. # You can pass arbitrary parameters to the plugin. `input.parameters` is a map, but values may be any type.
  24. # These parameters will also be available on the generator's output under the `generator.input.parameters` key.
  25. input:
  26. parameters:
  27. key1: "value1"
  28. key2: "value2"
  29. list: ["list", "of", "values"]
  30. boolean: true
  31. map:
  32. key1: "value1"
  33. key2: "value2"
  34. key3: "value3"
  35. # You can also attach arbitrary values to the generator's output under the `values` key. These values will be
  36. # available in templates under the `values` key.
  37. values:
  38. value1: something
  39. # When using a Plugin generator, the ApplicationSet controller polls every `requeueAfterSeconds` interval (defaulting to every 30 minutes) to detect changes.
  40. requeueAfterSeconds: 30
  41. # to automatically discover repositories within an organization
  42. - scmProvider:
  43. # Which protocol to clone using.
  44. cloneProtocol: ssh
  45. # The GitHub mode uses the GitHub API to scan an organization in either github.com or GitHub Enterprise
  46. github:
  47. # The GitHub organization to scan.
  48. organization: myorg
  49. # For GitHub Enterprise:
  50. api: https://git.example.com/
  51. # If true, scan every branch of every repository. If false, scan only the default branch. Defaults to false.
  52. allBranches: true
  53. # Reference to a Secret containing an access token. (optional)
  54. tokenRef:
  55. secretName: github-token
  56. key: token
  57. # (optional) use a GitHub App to access the API instead of a PAT.
  58. appSecretName: gh-app-repo-creds
  59. #Pass additional key-value pairs via values field
  60. values:
  61. name: "{{organization}}-{{repository}}"
  62. #The GitLab mode uses the GitLab API to scan and organization in either gitlab.com or self-hosted GitLab.
  63. gitlab:
  64. #The Gitea mode uses the Gitea API to scan organizations in your instance
  65. gitea:
  66. #Use the Bitbucket Server API (1.0) to scan repos in a project.
  67. bitbucketServer:
  68. #Uses the Azure DevOps API to look up eligible repositories
  69. azureDevOps:
  70. # The Bitbucket mode uses the Bitbucket API V2 to scan a workspace in bitbucket.org
  71. bitbucket:
  72. #Uses AWS ResourceGroupsTagging and AWS CodeCommit APIs to scan repos across AWS accounts and regionsz
  73. awsCodeCommit:
  74. #Filters allow selecting which repositories to generate for.
  75. filters:
  76. # Include any repository starting with "myapp" AND including a Kustomize config AND labeled with "deploy-ok" ...
  77. - repositoryMatch: ^myapp
  78. pathsExist: [kubernetes/kustomization.yaml]
  79. labelMatch: deploy-ok
  80. # ... OR include any repository starting with "otherapp" AND a Helm folder and doesn't have file disabledrepo.txt.
  81. - repositoryMatch: ^otherapp
  82. pathsExist: [helm]
  83. pathsDoNotExist: [disabledrepo.txt]
  84. # matrix 'parent' generator
  85. - matrix:
  86. generators:
  87. # any of the top-level generators may be used here instead.
  88. # merge 'parent' generator
  89. # Use the selector set by both child generators to combine them.
  90. - merge:
  91. mergeKeys:
  92. - server
  93. # Note that this would not work with goTemplate enabled,
  94. # nested merge keys are not supported there.
  95. - values.selector
  96. generators:
  97. - clusters:
  98. values:
  99. kafka: 'true'
  100. redis: 'false'
  101. # For clusters with a specific label, enable Kafka.
  102. - clusters:
  103. selector:
  104. matchLabels:
  105. use-kafka: 'false'
  106. values:
  107. kafka: 'false'
  108. # For a specific cluster, enable Redis.
  109. - list:
  110. elements:
  111. - server: https://2.4.6.8
  112. values.redis: 'true'
  113. # Determines whether go templating will be used in the `template` field below.
  114. goTemplate: true
  115. # Optional list of go templating options, see https://pkg.go.dev/text/template#Template.Option
  116. # This is only relevant if `goTemplate` is true
  117. goTemplateOptions: ["missingkey=error"]
  118. # These fields are identical to the Application spec.
  119. # The generator's template field takes precedence over the spec's template fields
  120. template:
  121. metadata:
  122. name: test-hello-world-app
  123. spec:
  124. project: my-project
  125. syncPolicy:
  126. automated:
  127. selfHeal: true
  128. syncOptions:
  129. - CreateNamespace=true
  130. # defines from which Git repository to extract the desired Application manifests
  131. source:
  132. - chart: '{{.chart}}'
  133. # developers may customize app details using JSON files from above repo URL
  134. repoURL: https://github.com/argoproj/argo-cd.git
  135. targetRevision: HEAD
  136. # Path within the repository where Kubernetes manifests are located
  137. path: applicationset/examples/list-generator/guestbook/{{cluster}}
  138. helm:
  139. useCredentials: "{{.useCredentials}}" # This field may NOT be templated, because it is a boolean field
  140. parameters:
  141. - name: "image.tag"
  142. value: "pull-{{head_sha}}"
  143. - name: "{{.name}}"
  144. value: "{{.value}}"
  145. - name: throw-away
  146. value: "{{end}}"
  147. destination:
  148. # Only one of name or server may be specified: if both are specified, an error is returned.
  149. # Name of the cluster (within Argo CD) to deploy to
  150. name: production-cluster # cluster is restricted
  151. # API Server URL for the cluster
  152. server: '{{.url}}'
  153. # Target namespace in which to deploy the manifests from source
  154. namespace: dev-team-one # namespace is restricted
  155. # This sync policy pertains to the ApplicationSet, not to the Applications it creates.
  156. syncPolicy:
  157. # Prevents ApplicationSet controller from modifying or deleting Applications
  158. applicationsSync: create-only
  159. # Prevents ApplicationSet controller from deleting Applications. Update is allowed
  160. # applicationsSync: create-update
  161. # Prevents ApplicationSet controller from modifying Applications. Delete is allowed.
  162. # applicationsSync: create-delete
  163. syncOptions:
  164. - CreateNamespace=true
  165. # Prevent an Application's child resources from being deleted, when the parent Application is deleted
  166. preserveResourcesOnDeletion: true
  167. # which fields of the ApplicationSet should be ignored when comparing Applications.
  168. ignoreApplicationDifferences:
  169. - jsonPointers:
  170. - /spec/source/targetRevision
  171. - name: some-app
  172. jqExpressions:
  173. - .spec.source.helm.values
  174. strategy:
  175. # This field lets you define fields which should be ignored when applying Application resources. This is helpful if you
  176. # want to use ApplicationSets to create apps, but also want to allow users to modify those apps without having their
  177. # changes overwritten by the ApplicationSet.
  178. # This update strategy allows you to group Applications by labels present on the generated Application resources
  179. type: RollingSync
  180. rollingSync:
  181. steps:
  182. # Application groups are selected using their labels and matchExpressions
  183. - matchExpressions:
  184. - key: envLabel
  185. operator: In
  186. values:
  187. - env-dev
  188. # maxUpdate: 100% # if undefined, all applications matched are updated together (default is 100%)
  189. - matchExpressions:
  190. - key: envLabel
  191. operator: In
  192. values:
  193. - env-qa
  194. maxUpdate: 0 # if 0, no matched applications will be synced unless they're synced manually
  195. - matchExpressions:
  196. - key: envLabel
  197. operator: In
  198. values:
  199. - env-prod
  200. maxUpdate: 10% # maxUpdate supports both integer and percentage string values (rounds down, but floored at 1 Application for >0%)
  201. ignoreApplicationDifferences:
  202. - jsonPointers:
  203. - /spec/source/targetRevision
  204. - name: some-app
  205. jqPathExpressions:
  206. - .spec.source.helm.values
  207. # Cluster-decision-resource-based ApplicationSet generator
  208. - clusterDecisionResource:
  209. # ConfigMap with GVK information for the duck type resource
  210. configMapRef: my-configmap
  211. name: quak # Choose either "name" of the resource or "labelSelector"
  212. labelSelector:
  213. matchLabels: # OPTIONAL
  214. duck: spotted
  215. matchExpressions: # OPTIONAL
  216. - key: duck
  217. operator: In
  218. values:
  219. - "spotted"
  220. - "canvasback"
  221. # OPTIONAL: Checks for changes every 60sec (default 3min)
  222. requeueAfterSeconds: 60
  223. # The Pull Request generator uses the API of an SCMaaS provider to automatically discover open pull requests within a repository
  224. - pullRequest:
  225. # When using a Pull Request generator, the ApplicationSet controller polls every `requeueAfterSeconds` interval (defaulting to every 30 minutes) to detect changes.
  226. requeueAfterSeconds: 1800
  227. # See below for provider specific options.
  228. # Specify the repository from which to fetch the GitHub Pull requests.
  229. github:
  230. # The GitHub organization or user.
  231. owner: myorg
  232. # The Github repository
  233. repo: myrepository
  234. # For GitHub Enterprise (optional)
  235. api: https://git.example.com/
  236. # Reference to a Secret containing an access token. (optional)
  237. tokenRef:
  238. secretName: github-token
  239. key: token
  240. # (optional) use a GitHub App to access the API instead of a PAT.
  241. appSecretName: github-app-repo-creds
  242. # Labels is used to filter the PRs that you want to target. (optional)
  243. labels:
  244. - preview
  245. # Filters allow selecting which pull requests to generate for
  246. # Include any pull request ending with "argocd". (optional)
  247. filters:
  248. - branchMatch: ".*-argocd"
  249. # Specify the project from which to fetch the GitLab merge requests.
  250. gitlab:
  251. # Specify the repository from which to fetch the Gitea Pull requests.
  252. gitea:
  253. # Fetch pull requests from a repo hosted on a Bitbucket Server (not the same as Bitbucket Cloud).
  254. bitbucketServer:
  255. # Fetch pull requests from a repo hosted on a Bitbucket Cloud.
  256. bitbucket:
  257. # Specify the organization, project and repository from which you want to fetch pull requests.
  258. azuredevops:
  259. # Fetch pull requests from AWS CodeCommit repositories.
  260. awsCodeCommit:
  261. # The list generator generates a set of two application which then filter by the key value to only select the env with value staging
  262. - list:
  263. elements:
  264. - cluster: engineering-dev
  265. url: https://kubernetes.default.svc
  266. env: staging
  267. - cluster: engineering-prod
  268. url: https://kubernetes.default.svc
  269. env: prod
  270. # The generator's template field takes precedence over the spec's template fields
  271. template:
  272. metadata: {}
  273. spec:
  274. project: "default"
  275. source:
  276. revision: HEAD
  277. repoURL: https://github.com/argoproj/argo-cd.git
  278. # New path value is generated here:
  279. path: 'applicationset/examples/template-override/{{cluster}}-override'
  280. destination: {}
  281. selector:
  282. matchLabels:
  283. env: staging
  284. # It is also possible to use matchExpressions for more powerful selectors
  285. - clusters: {}
  286. selector:
  287. matchExpressions:
  288. - key: server
  289. operator: In
  290. values:
  291. - https://kubernetes.default.svc
  292. - https://some-other-cluster